



# 登录
from utils.get_keyword import GetKeyword
from utils.request_method import SendMethod
from interface.member import MemberInterface


class CartInterface:

    def __init__(self, headers):
        self.url = 'http://47.108.206.100:8085'
        self.headers = headers



   #登录
    def login(self,body):
        method='post'
        url=self.url +'/sso/login'
        body={
            "username":"海绵宝宝",
            "password":'123456'
        }
        return SendMethod.send_method(method,url,data=body)

    #添加购物车
    def add_cart(self, params):
        method = 'post'
        url = self.url + '/cart/add'
        return SendMethod.send_method(method, url, json=params, headers=self.headers)


if __name__ == '__main__':
    body = {
        "username":"海绵宝宝",
        "password":'123456'
    }
    headers=MemberInterface().get_token_head(body)
    print(headers)
    cartItem={
        "createDate": "2022-10-21T01:21:49.268Z",
        "deleteStatus": 0,
        "id": 0,
        "memberId": 27,
        "memberNickname": "string",
        "modifyDate": "2022-10-21T01:21:49.268Z",
        "price": 2999,
        "productAttr": '[{"key":"颜色","value":"黑色"},{"key":"容量","value":"64G"}]',
        "productBrand": "中兴",
        "productCategoryId": 19,
        "productId": 27,
        "productName": "中兴01",
        "productPic": "http://www.tupian.com",
        "productSkuCode": "201808270027002",
        "productSkuId": 99,
        "productSn": "666466",
        "productSubTitle": "AI智慧全面屏 6GB +64GB 亮黑色 全网通版 移动联通电信4G手机 双卡双待手机 双卡双待",
        "quantity": 1
    }
    ci=CartInterface(headers)
    print(ci.add_cart(cartItem))









